<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="<c:url value="/css/style.css"/>" />
<script type="text/javascript" src="<c:url value="/js/script.js"/>" ></script>
<title>Article items</title>
</head>
<body>
	<table border="0" width = "80%" align="center">
		<tr>
			<td><jsp:include page="header.jsp" /></td>
		</tr>
		<tr>	
			<td>
				<table border="0" width = "100%">
					<tr>
						<td align = "left">
						<!-- Article type : -->
						<bean:write	name="articlePresentationForm" property="articleDTO.articleType" />
						</td>
						<td align = "right">
						<c:if test="${articlePresentationForm.articleDTO.authorId == requestScope.userId}">
						<a href="updateArticleAction.do?articleId=${articlePresentationForm.articleDTO.articleId}">Edit</a>
						&nbsp; 
						<a href="javascript:confirmDelete('deleteArticleAction.do?articleId=${articlePresentationForm.articleDTO.articleId}')" >Delete</a>
						</c:if>
						</td>
																	
					</tr>
				</table>
			</td>
		</tr>
		<tr>	
			<td>
				<!-- Title : -->	
				<arttitle>
				<bean:write name="articlePresentationForm" property="articleDTO.title" />
				</arttitle>
			</td>
		</tr>
		<tr>	
			<td bgcolor = "#f5f5f5">
				<author>
				<bean:write name="articlePresentationForm" property="articleDTO.byline.author" />
				<bean:write name="articlePresentationForm" property="articleDTO.byline.timestamp" />
				<bean:write name="articlePresentationForm" property="articleDTO.byline.ip" />
				<bean:write name="articlePresentationForm" property="articleDTO.byline.rating" />
				<bean:write name="articlePresentationForm" property="articleDTO.byline.hitCount" />
				</author>
			</td>
		</tr>		
		<tr>	
			<td>
				<!-- Summary : --><br>
				<!--<bean:write name="articlePresentationForm" property="articleDTO.summary" />-->
				<summary>
					<c:out value="${articlePresentationForm.articleDTO.summary}" escapeXml="false" />
				</summary>
			</td>
		</tr>
		<tr>	
			<td>				
				<!-- Body : --><br>
				<!--<bean:write name="articlePresentationForm" property="articleDTO.body" />-->
				<c:out value="${articlePresentationForm.articleDTO.body}" escapeXml="false" />
				<br><br>
			</td>
		</tr>
		<tr>	
			<td bgcolor = "#f5f5f5"> 
				Keywords : 
				<bean:write	name="articlePresentationForm" property="articleDTO.keywords" />
			</td>
		</tr>
		<tr>
			<td>
				All Versions :
				<logic:iterate name="articlePresentationForm" 
					property="articleDTO.articleVersionDTOList" id="data" indexId="index">
				&nbsp;
				<a href="articleVersionPresentationAction.do?articleVersionId=${data.versionId}">
					${articlePresentationForm.articleDTO.articleVersionDTOListSize-index}
				</a>
				</logic:iterate>
			</td>
		</tr>
		<tr>
			<td>				
				<br>	
			</td>
		</tr>
		<tr>
			<td>
				<table border="0" width="100%">
					<tr>	
						<td align = "left" valign = "top" width = "60%">
							<html:form action="/articleCommentAction.do?articleId=${articlePresentationForm.articleDTO.articleId}">
								Comment this article (<html:text name="articlePresentationForm" property="countdown" size="3" value="500"></html:text> characters left)<br>
							    <html:textarea name="articlePresentationForm" property="comment" cols="40" rows="5"
							    	onkeydown="javascript:limitText(this.form.comment,this.form.countdown,500);" 
									onkeyup="javascript:limitText(this.form.comment,this.form.countdown,500);">
								</html:textarea><br>								
							    <html:submit/>
						    </html:form>
						</td>
						<td align = "left" valign = "top" width = "40%">
							<html:form action="/articleRatingAction.do?articleId=${articlePresentationForm.articleDTO.articleId}">
						    Rate this article
						    <table border="0">
						       	<tr bgcolor="#f5f5f5">
							   		<td><html:radio name="articlePresentationForm" property="rating" value="0" /></td>
							        <td><html:radio name="articlePresentationForm" property="rating" value="1" /></td>
							        <td><html:radio name="articlePresentationForm" property="rating" value="2" /></td>
							        <td><html:radio name="articlePresentationForm" property="rating" value="3" /></td>
							        <td><html:radio name="articlePresentationForm" property="rating" value="4" /></td>
							        <td><html:radio name="articlePresentationForm" property="rating" value="5" /></td>
							        <td><html:radio name="articlePresentationForm" property="rating" value="6" /></td>
							        <td><html:radio name="articlePresentationForm" property="rating" value="7" /></td>
							        <td><html:radio name="articlePresentationForm" property="rating" value="8" /></td>
							        <td><html:radio name="articlePresentationForm" property="rating" value="9" /></td>
							        <td><html:radio name="articlePresentationForm" property="rating" value="10" /></td>
			   			       	</tr>
						       	<tr bgcolor="#f5f5f5">
						       		<td align="center">0</td>
						       		<td align="center">1</td>
						       		<td align="center">2</td>
						       		<td align="center">3</td>
						       		<td align="center">4</td>
						       		<td align="center">5</td>
						       		<td align="center">6</td>
						       		<td align="center">7</td>
						       		<td align="center">8</td>
						       		<td align="center">9</td>
						       		<td align="center">10</td>			            		  
						       	</tr>
						     </table>
						     <html:submit/>
						     </html:form>
			   			</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>	
			<td>				 				
				Comments:<br><br>
			</td>
		</tr>
		<tr>	
			<td>			
				<table border="0" width="100%">					
				<logic:iterate name="articlePresentationForm" property="articleDTO.articleCommentDTOList" id="data">
					<tr>
						<td bgcolor = "#f5f5f5">
							<!-- Username/timestamp/IP -->
							<author>							
								<bean:write name="data" property="byline.author" /> 
								<bean:write name="data" property="byline.timestamp" />
								<bean:write name="data" property="byline.ip" />
							</author>
						</td>					
					</tr>
					<tr>
						<td>
							<!-- Comment -->
							<!--<bean:write name="data" property="comment" /><br><br>-->
							<c:out value="${data.comment}" escapeXml="false" />
							<br><br> 		
						</td>					
					</tr>
				</logic:iterate>
				</table>
			</td>
		</tr>
		<tr>
			<td>				
				<jsp:include page="footer.jsp" />	
			</td>
		</tr>
	</table>
	<!-- 
	<s:property escapeHtml="false" value="articlePresentationForm.articleBody.replace(\"\r\n\", \"&lt;br&gt;\")" />
	 -->
</body>
</html>
